import { configure, makeAutoObservable } from "mobx";
import { LeaseEntity } from "@/entities/LeaseEntity";

configure({
  enforceActions: "always",
});

class LeaseStore {
  constructor() {
    makeAutoObservable(this, {}, { autoBind: true });
  }

  /**
   * 租客租赁的房屋列表
   */
  leaseHouseList: any = [];

  /**
   * 当前租赁房屋
   */
  currentLeaseHouse: any = {};

  /**
   * 待处理租赁申请
   */
  pendingLeaseList: any | Array<LeaseEntity.IPendingLease> = [];

  /**
   * 当前正在被收租的租客
   */
  currentRentBillTenant: LeaseEntity.IExistLease | any = {
    houseAddress: "广东省深圳市南山区桃园路",
    houseId: 5,
    houseName: "豪门单身公寓",
    landlordId: 12,
    leaseDate: "2024-12-21T15:05:33.000Z",
    leaseMonths: 13,
    tenantHeadImg: "/upload_1734682148167.0.1396289794714498.0.jpg",
    tenantId: 4,
    tenantName: "帅气租客yo",
    tenantPhone: "18453793540",
  };

  /**
   * 设置租客租赁的房屋
   * @param leaseHouseList 租赁房屋列表
   */
  setLeaseHouse(leaseHouseList: LeaseEntity.IHouseLease[]) {
    this.leaseHouseList = leaseHouseList;
  }

  /**
   * 清除租客租赁的房屋
   */
  clearLeaseHouse() {
    this.leaseHouseList = [];
  }

  /**
   * 设置当前租赁房屋
   * @param leaseHouse 租赁房屋
   */
  setCurrentLeaseHouse(leaseHouse: LeaseEntity.IHouseLease) {
    this.currentLeaseHouse = leaseHouse;
  }

  /**
   * 设置待处理租赁申请
   */
  setPendingLeaseList(pendingLeaseList: LeaseEntity.IPendingLease) {
    this.pendingLeaseList = pendingLeaseList;
  }

  /**
   * 清除待处理租赁申请
   */
  clearPendingLeaseList() {
    this.pendingLeaseList = [];
  }

  /**
   * 设置当前正在被收租的租客
   */
  setCurrentRentBillTenant(leaseTenant: LeaseEntity.IExistLease) {
    this.currentRentBillTenant = leaseTenant;
  }
}

const leaseStore = new LeaseStore();
export default leaseStore;
